<template>
	<view class="content">
		<scroll-view style="height: calc(100vh - 80rpx);" class="wid100" scroll-y="true" @scrolltolower="lower">
			<view style="height: 1rpx;"></view>
			<block v-for="(item,index) in list" :key="index">
				<view class="wid100 bacFFF mar-top30" style="padding: 25rpx 0;" @click="tiaozhuan('/pages/store/particulars?id='+item.id)">
					<view class="wid87 mar">
						<view class="dis disAl disJuB foSi25" style="color: #5B5B5B;">
							<view>兑换单号：{{item.order_num}}</view>
							<view v-if="item.revoke_state == 0">
								<view v-if="item.writeoff_state == 0" style="color: #FF0000;">待核销</view>
								<view v-if="item.writeoff_state == 1" style="color: #035DFF;">已核销</view>
							</view>
							<view v-if="item.revoke_state == 1"> 已撤销 </view>
						</view>
						<view class="dis" style="margin-top: 35rpx;">
							<image :src="url+item.goods.pic" class="img"></image>
							<view class="wid80" style="margin-left: 32rpx;">
								<view class="foSi30 fowe600">{{item.goods.name}}</view>
								<view class="mar-top10 foSi25">x{{item.num}}</view>
								<view class="dis disAl disJuB">
									<view class="foSi18">兑换日期：{{item.createtime}}</view>
									<view class="foSi25" style="color: #FF0000;">-{{item.integral}}积分</view>
								</view>
							</view>
						</view>
						<view class="dis mar-top40" style="justify-content: flex-end;">
							
							<view v-if="item.revoke_state == 0">
								<view v-if="item.writeoff_state == 1" @click.stop="tiaozhuan('/pages/store/store')"
									class="dis disAl disJuC foSi20 fowe600 borRad40" style="width: 132rpx;height: 44rpx;border: 1rpx solid #3A3A3A;color: #3A3A3A;">再次兑换</view>
								<view v-if="item.writeoff_state == 0"
									class="dis disAl disJuC foSi20 fowe600 borRad40"  style="width: 132rpx;height: 44rpx;border: 1rpx solid #FF0000;color: #FF0000;">核销码</view>
							</view>
						</view>
					</view>
				</view>
			</block>
			<view v-if="list.length == 0" class="wid90 mar fowe800 foSi35">
				<view style="height: 50rpx;"></view>
				<view class="dis disJuC">
					<image src="../../static/zanwu2.png" style="width: 400rpx;height: 300rpx;"></image>
				</view>
				<view class="textCen mar-top20" style="color: #868686;">暂无数据</view>
			</view>
			<view style="height: 50rpx;"></view>
		</scroll-view>
	</view>
</template>

<script>
	export default {
		data() {
			return {
				url: this.global.url,
				list: [],
				last_page: 0,
				page: 1,
				biaoji: 0
			}
		},
		onLoad(option) {
			this.biaoji = option.biaoji
		},
		onShow() {
			this.page = 1
			this.getList()
		},
		methods: {
			getList() {
				var that = this;
				uni.request({
					url: that.global.url + '/api/qianyu_petrol/gasstation_integralorder_lists',
					method: "POST",
					header: {
						'site-id': that.global.site_id, //自定义请求头信息
						'token': uni.getStorageSync('token')
					},
					data: {
						page: that.page,
						limit: 10,
					},
					success(res) {
						let result = res.data
						console.log(result)
						if (result.code == 1) {
							that.last_page = result.data.last_page
							if(that.page == 1){
								that.list = result.data.data
							}else{
								that.list = that.list.concat(result.data.data)
							}
						}
					}
				})
			},
			lower(e) {
				if(this.last_page > this.page){
					this.page++
					this.getList()
				}
			},
			tiaozhuan(url) {
				if(this.biaoji == 0 && url == '/pages/store/store'){
					uni.navigateBack()
				}else{
					uni.navigateTo({
						url: url
					})
				}
			},
		}
	}
</script>

<style>
	.content {
		background: #F8F9FD;
		height: 100vh;
	}
	.img{
		min-width: 108.1rpx;
		min-height: 108.1rpx;
		width: 108.1rpx;
		height: 108.1rpx;
	}
</style>
